#!/bin/bash 


BASEDIR=/opt/mysqlbackup;
MYSQLUSER=root
MYSQLHOST=172.17.0.1
DATABASES='db1 db2'
mkdir -p ${BASEDIR}/sql;

mysqldump -u${MYSQLUSER} -h${MYSQLHOST} --opt --single-transaction -B ${DATABASES} > ${BASEDIR}/sql/dbbackup.sql

bakfilename=dbbackup-`date +%Y%m%d%H`.tgz
tar zcf ${BASEDIR}/${bakfilename} ${BASEDIR}/sql/dbbackup.sql;
#scp ${BASEDIR}/${bakfilename} root@remote:/opt/mysql_backup
#rm -rf ${BASEDIR}/${bakfilename};
#rm -rf ${BASEDIR}/sql/dbbackup.sql;